package com.muyu.cloud.commodity.controller;

import com.muyu.cloud.commodity.domain.model.SpecValue;
import com.muyu.cloud.commodity.service.SpecValueService;

import com.muyu.common.core.domain.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/product/spec/value")
@Tag(name = "SpecValueController", description = "规格值管理")
public class SpecValueController {

    @Autowired
    private SpecValueService specValueService;

    /**
     * 查询规格值
     * @param groupId
     * @return
     */
    @Operation(summary = "按规格组查询规格值")
    @GetMapping("/listByGroup")
    public Result<List<SpecValue>> listByGroup(@RequestParam("groupId") Long groupId) {
        return Result.success(specValueService.listByGroupId(groupId));
    }

    /**
     * 按分类查询规格值
     * @param categoryId
     * @return
     */
    @Operation(summary = "按分类查询所有规格值")
    @GetMapping("/listByCategory")
    public Result<List<SpecValue>> listByCategory(@RequestParam("categoryId") Long categoryId) {
        return Result.success(specValueService.listByCategoryId(categoryId));
    }
}


